﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class LUONGGD
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        private String MALUONGGD, MAGV;
        private int HOCKI, NAMHOC;
        private float TONGTIETGIANGDAY, TONGLUONGGD;

        public String maluonggd
        {
            get { return MALUONGGD; }
            set { MALUONGGD = value; }
        }

        public String magv
        {
            get { return MAGV; }
            set { MAGV = value; }
        }
        public int hocki
        {
            get { return HOCKI; }
            set { HOCKI = value; }
        }

        public int namhoc
        {
            get { return NAMHOC; }
            set { NAMHOC = value; }
        }
        public float tongtietgiangday
        {
            get { return TONGTIETGIANGDAY; }
            set { TONGTIETGIANGDAY = value; }
        }

        public float luonggd
        {
            get { return TONGLUONGGD; }
            set { TONGLUONGGD = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dtgLuongCB"></param>
        /// 
        public void hienthi_LuongGD(DataGridView dtgLuongGD)
        {
            String excuteString = "SELECT * FROM BANGLUONGGD";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgLuongGD.DataSource = dataTable;
        }

        public void xoa_LuongGD(String maluongGD)
        {
            String excuteString = "DELETE FROM BANGLUONGGD WHERE MALUONGGD='" + maluongGD+ "';";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void them_LuongGD(LUONGGD luongGD)
        {
            String excuteString = "INSERT INTO BANGLUONGGD VALUES('" + luongGD.maluonggd + "','"
                                                                 + luongGD.magv + "',"
                                                                 + luongGD.hocki + ","
                                                                 + luongGD.namhoc + ","
                                                                 + luongGD.tongtietgiangday + ","
                                                                 + luongGD.luonggd + ")";


            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_LuongGD(LUONGGD luongGD)
        {
            String excuteString = "UPDATE BANGLUONGGD SET MAGV='" + luongGD.magv +
                                                  "',HOCKI =" + luongGD.hocki +
                                                  ",NAMHOC =" + luongGD.namhoc +
                                                  ",TONGTIETGIANGDAY =" + luongGD.tongtietgiangday +
                                                  ",TIENLUONGGD =" + luongGD.luonggd +
                                                  " WHERE MALUONGGD='" + luongGD.maluonggd + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }
    }
}
